package com.example.JPetStore.mappers;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.JPetStore.domain.Cart;
import com.example.JPetStore.domain.Order;
import com.example.JPetStore.dto.CartDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CartMapper extends BaseMapper<Cart> {
    @Select("SELECT a.*,b.* FROM carts a inner join items b on a.item_id =b.item_id where user_id = #{user_id}")
    List<CartDto> queryCarts(@Param("user_id") String userId);
    @Select("SELECT a.*,b.* FROM carts a inner join items b on a.item_id =b.item_id where a.user_id = #{user_id} and a.cart_id=#{cart_id}")
    CartDto queryCartById(@Param("cart_id") String cartId,@Param("user_id") String userId);

}
